﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LabMS.Web.Equipment.LowValue
{
    public partial class lowrepair : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("DZPWX");//必须写在ispostback外
            strPageUserType.Add("mana");
            if (!Page.IsPostBack)
                bind(" Type='lowvalue' and GoodsMaintain.Status='故障 '");
        }

        public void bind(string strWhere)
        {
            ExtendBLL.GoodsMaintain bgoodsmaintain = new ExtendBLL.GoodsMaintain();
            List<ExtendModule.GoodsMaintain> goodsmaintain = bgoodsmaintain.GetExtendModuleList(strWhere);
            instrumentsRepair.DataSource = goodsmaintain;
            instrumentsRepair.DataBind();
        }

        protected void lbSearch_Click(object sender, EventArgs e)
        {
            if (tbKeyWords.Text.Trim().Equals(""))
                return;
            else
                bind(" Type='lowvalue' and GoodsMaintain.Status='故障' and GoodsMaintain." + ddlCClass.SelectedValue + " like '%" + tbKeyWords.Text.Trim() + "%'");
        }

        protected void lbRefresh_Click(object sender, EventArgs e)
        {
            bind(" Type='lowvalue' and GoodsMaintain.Status='故障'");
        }

        protected void instrumentsRepair_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
            //    e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
            //    e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");
                e.Row.Attributes["style"] = "Cursor:pointer";
                int itemp = e.Row.Cells.Count;
                for (int i = 1; i < itemp; i++)
                {
                    e.Row.Cells[i].Attributes.Add("OnDblClick", "window.location.href='lowrepair.aspx?ID=" + instrumentsRepair.DataKeys[instrumentsRepair.DataKeys.Count - 1].Value.ToString() + "'");
                }


            }
        }

        protected void instrumentsRepair_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            instrumentsRepair.PageIndex = e.NewPageIndex;
            if (tbKeyWords.Text.Trim().Equals(""))
            {
                bind(" Type='lowvalue' and GoodsMaintain.Status='故障 '");
            }
            else
            {
                string strWhere = " Type='lowvalue' and GoodsMaintain.Status='故障' and GoodsMaintain." + ddlCClass.SelectedValue + " like '%" + tbKeyWords.Text.Trim() + "%'";
                bind(strWhere);
            }
        }


    }
}
